﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NetFrameworkExtensions.BusinessLayer.Properties;

namespace NetFrameworkExtensions.BusinessLayer
{
  public static class ObjectSource
  {
    private static Func<IObjectSource> provider;

    public static IObjectSource Current { get { return provider(); } }

    public static void SetServiceManagerProvider(Func<IObjectSource> newProvider)
    {
      if (newProvider == null)
        throw new ArgumentNullException("newProvider");
      if (provider == null)
        provider = newProvider;
      else
        throw new InvalidOperationException(FormattedResources.CannotResetObjectSourceProvider);
    }
  }
}
